﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Nature.Data.GMixMarkup
{
    public partial class GMixComponentItem
    {
        Nature.Toolkit.GMix.ILhs m_lhs;
        Nature.Toolkit.GMix.IRhs m_rhs;

        public Nature.Toolkit.GMix.IRhs Rhs
        {
            get 
            {
                if (this.Parameter != null)
                {                    
                    return (m_rhs = this.Parameter);
                }
                else
                {
                    return (m_rhs = Nature.Toolkit.GMix.Generic.Rhs.Value(this.Value));
                }
            }
        }

        public Nature.Toolkit.GMix.ILhs Lhs
        {
            get 
            {                
                if (m_lhs != null) { return m_lhs; }
                if (this.SpeciesID != null)
                {
                    return (m_lhs = new Nature.Toolkit.GMix.Generic.LhsSpecies(this.SpeciesID));
                }
                else if (this.ComponentID != null)
                {
                    return (m_lhs = new Nature.Toolkit.GMix.Generic.LhsComponent(this.ComponentID));
                }
                else if (this.LhsKnownType.HasValue)
                {
                    switch (this.LhsKnownType.Value)
                    {
                        case (KnownItemType.Temperature):
                            return (m_lhs = new Nature.Toolkit.GMix.Generic.LhsTemperatuire());
                        case (KnownItemType.Pressure):
                            return (m_lhs = new Nature.Toolkit.GMix.Generic.LhsPressure());
                        case (KnownItemType.BaseTemperature):
                            return (m_lhs = new Nature.Toolkit.GMix.Generic.LhsTemperatuireBase());
                        case (KnownItemType.BasePressure):
                            return (m_lhs = new Nature.Toolkit.GMix.Generic.LhsPressureBase());
                        case (KnownItemType.CompressionRatio):
                            return (m_lhs = new Nature.Toolkit.GMix.Generic.LhsCompressionRatio());
                        case (KnownItemType.MachNumber):
                            return (m_lhs = new Nature.Toolkit.GMix.Generic.LhsMachNumber());
                        case (KnownItemType.EquivalenceRatio):
                            return (m_lhs = new Nature.Toolkit.GMix.Generic.LhsEquivalenceRatio());
                        case (KnownItemType.MixtureFraction):
                            return (m_lhs = new Nature.Toolkit.GMix.Generic.LhsMixtureFraction());
                        default:
                            throw new NotSupportedException(this.LhsKnownType.Value.ToString());
                    }
                }
                else
                {
                    throw new NotSupportedException();
                }
            }
        }
    }
}
